import { Action } from '@ngrx/store';
import { TaskList, User } from '../domain/index';

/**
 * For each action type in an action group, make a simple
 * enum object for all of this group's action types.
 */
export enum TaskListActionTypes {
    ADD = '[TaskList] Add',
    ADD_SUCCESS = '[TaskList] Add Success',
    ADD_FAIL = '[TaskList] Add Fail',
    UPDATE = '[TaskList] Update',
    UPDATE_SUCCESS = '[TaskList] Update Success',
    UPDATE_FAIL = '[TaskList] Update Fail',
    DELETE = '[TaskList] Delete',
    DELETE_SUCCESS = '[TaskList] Delete Success',
    DELETE_FAIL = '[TaskList] Delete Fail',
    LOAD = '[TaskList] Load',
    LOAD_SUCCESS = '[TaskList] Load Success',
    LOAD_FAIL = '[TaskList] Load Fail',
    SWAP = '[TaskList] Swap',
    SWAP_SUCCESS = '[TaskList] Swap Success',
    SWAP_FAILE = '[TaskList] Swap Fail'
}

/**
 * Every action is comprised of at least a type and an optional
 * payload. Expressing actions as classes enables powerful
 * type checking in reducer functions.
 */
export class TaskListAddAction implements Action {
    readonly type = TaskListActionTypes.ADD;
    constructor(public payload: TaskList) { }
}

export class TaskListAddSuccessAction implements Action {
    readonly type = TaskListActionTypes.ADD_SUCCESS;
    constructor(public payload: TaskList) { }
}
export class TaskListAddFailAction implements Action {
    readonly type = TaskListActionTypes.ADD_FAIL;
    constructor(public payload: string) { }
}

export class TaskListUpdateAction implements Action {
    readonly type = TaskListActionTypes.UPDATE;
    constructor(public payload: TaskList) { }
}

export class TaskListUpdateSuccessAction implements Action {
    readonly type = TaskListActionTypes.UPDATE_SUCCESS;
    constructor(public payload: TaskList) { }
}
export class TaskListUpdateFailAction implements Action {
    readonly type = TaskListActionTypes.UPDATE_FAIL;
    constructor(public payload: string) { }
}

export class TaskListDeleteAction implements Action {
    readonly type = TaskListActionTypes.DELETE;
    constructor(public payload: TaskList) { }
}

export class TaskListDeleteSuccessAction implements Action {
    readonly type = TaskListActionTypes.DELETE_SUCCESS;
    constructor(public payload: TaskList) { }
}

export class TaskListDeleteFailAction implements Action {
    readonly type = TaskListActionTypes.DELETE_FAIL;
    constructor(public payload: string) { }
}

export class TaskListLoadAction implements Action {
    readonly type = TaskListActionTypes.LOAD;
    constructor(public payload: string) { }
}

export class TaskListLoadSuccessAction implements Action {
    readonly type = TaskListActionTypes.LOAD_SUCCESS;
    constructor(public payload: TaskList[]) { }
}
export class TaskListLoadFailAction implements Action {
    readonly type = TaskListActionTypes.LOAD_FAIL;
    constructor(public payload: string) { }
}
export class TaskListSwapAction implements Action {
    readonly type = TaskListActionTypes.SWAP;
    constructor(public payload: { src: TaskList; target: TaskList }) { }
}

export class TaskListSwapSuccessAction implements Action {
    readonly type = TaskListActionTypes.SWAP_SUCCESS;
    constructor(public payload: TaskList[]) { }
}
export class TaskListSwapFailAction implements Action {
    readonly type = TaskListActionTypes.SWAP_FAILE;
    constructor(public payload: string) { }
}
/**
 * Export a type alias of all actions in this action group
 * so that reducers can easily compose action types
 */
export type TaskListActions
    = TaskListAddAction
    | TaskListAddSuccessAction
    | TaskListAddFailAction
    | TaskListUpdateAction
    | TaskListUpdateSuccessAction
    | TaskListUpdateFailAction
    | TaskListDeleteAction
    | TaskListDeleteSuccessAction
    | TaskListDeleteFailAction
    | TaskListLoadAction
    | TaskListLoadSuccessAction
    | TaskListLoadFailAction
    | TaskListSwapAction
    | TaskListSwapSuccessAction
    | TaskListSwapFailAction;
